

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main" />
    <title>Edit User</title>
  </head>
  <body>
  <g:render template="/menu" />
  <div class="body">
    <h1>Edit User</h1>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${userInstance}">
      <div class="errors">
        <g:renderErrors bean="${userInstance}" as="list" />
      </div>
    </g:hasErrors>
    <g:form method="post" enctype="multipart/form-data" >
      <input type="hidden" name="id" value="${userInstance?.id}" />
      <input type="hidden" name="version" value="${userInstance?.version}" />
      <div class="dialog">
        <table>
          <tbody>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="avatar">Photo:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:userInstance,field:'avatar','errors')}">
                <input type="file" name="avatar" id="avatar" value="${fieldValue(bean:userInstance,field:'avatar')}" />
              </td>
            </tr>


            <tr class="prop">
              <td valign="top" class="name">
                <label for="userName">User Name:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:userInstance,field:'userName','errors')}">
                <input type="text" id="userName" name="userName" value="${fieldValue(bean:userInstance,field:'userName')}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="passWord">Pass Word:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:userInstance,field:'passWord','errors')}">
                <input type="text" id="passWord" name="passWord" value="${fieldValue(bean:userInstance,field:'passWord')}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="dateOfBirth">Date Of Birth:</label>
              </td>
              <td valign="top" class="value ${hasErrors(bean:userInstance,field:'dateOfBirth','errors')}">
                <g:datePicker name="dateOfBirth" value="${userInstance?.dateOfBirth}" precision="minute" ></g:datePicker>
              </td>
            </tr>

            <% if ( session.user.role.equals("admin") ) { %>
              <tr class="prop">
                <td valign="top" class="name">
                  <label for="role">Role (admin or blank):</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'role','errors')}">
                  <input type="text" id="role" name="role" value="${fieldValue(bean:userInstance,field:'role')}"/>
                </td>
              </tr>
            <% } %>


          <!--
          <tr class="prop">
            <td valign="top" class="name">
              <label for="callDetails">Call Details:</label>
            </td>
            <td valign="top" class="value ${hasErrors(bean:userInstance,field:'callDetails','errors')}">

              <ul>
                <g:each var="c" in="${userInstance?.callDetails?}">
                  <li><g:link controller="callDetail" action="show" id="${c.id}">${c?.encodeAsHTML()}</g:link></li>
                </g:each>
              </ul>
          <g:link controller="callDetail" params="['user.id':userInstance?.id]" action="create">Add CallDetail</g:link>

          </td>
          </tr>
          -->

          </tbody>
        </table>
      </div>
      <div class="buttons">
        <span class="button"><g:actionSubmit class="save" value="Update" /></span>
        <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
      </div>
    </g:form>
  </div>
</body>
</html>
